﻿$(document).ready(function () {


    /**** 20120111 add ***/
    var yingyuan_top = $("#selcinemalch").offset().top;
    var yingyuanlist_h = $("#cinemasearchnew").height();
    //alert(yingyuanlist_h);
    /*** 20120111 end ***/
    /*** top pageTop ******/

    var $backToTopTxt = "返回顶部", $backToTopEle = $('<div class="backToTop"></div>').appendTo($("body"))
		.text($backToTopTxt).attr("title", $backToTopTxt).click(function () {
		    $("html, body").animate({ scrollTop: 0 }, 120);
		}), $backToTopFun = function () {
		    var st = $(document).scrollTop(), winh = $(window).height();
		    (st > 0) ? $backToTopEle.show() : $backToTopEle.hide();
		    //IE6下的定位
		    if (!window.XMLHttpRequest) {
		        $backToTopEle.css("top", st + winh - 66);
		    }
		};
    $(window).bind("scroll", $backToTopFun);
    $(function () { $backToTopFun(); });

    kchangecity2(cid);

    $("#selmovielch").mouseover(function () {
        $("#kchfilmname").addClass("newselh");
        $("#kchfilmname > b").addClass("newselhb");
        $("#moviesearchnew").show().removeClass("topsel-movieB").addClass("xlsel-movie_2");

        if ($("#tip").length > 0) {
            $("#kfilm").remove("#tip");
        } else {

            //alert("kfilm6");
            $("#kfilm").prepend("<div id='tip' style='font-size:12px;color:#369;'>正在上映的影片：</div>");
        }
        $("#kfilm>li>a:eq(1)").css("background", "none").css("position", "absolute").css("top", "0").css("right", "-15px");
        $("#kfilm>li").css("margin-right", "25px");
        $("#ktimesearchnew").hide();
        $("#cinemasearchnew").hide();
    });
    $("#selmovielch").mouseout(function () {
        $("#kchfilmname").removeClass("newselh");
        $("#kchfilmname > b").removeClass("newselhb");
        $("#moviesearchnew").hide();
    });
    $("#selcinemalch").mouseover(function () {
        $("#kchcinemaname").addClass("newselh");
        $("#kchcinemaname > b").addClass("newselhb");
        $("#cinemasearchnew").show();
        $("#moviesearchnew").hide();
        $("#ktimesearchnew").hide();
        if ($("#tips").length > 0) {
            $("#kcinema").remove("#tips");
        } else {
            $("#kcinema").prepend("<div id='tips' style='font-size:12px;color:#369;'>请选择您的影院：</div>");
        }
        $("#kcinema>li>span>a:eq(1)").css("position", "absolute").css("top", "2px").css("right", "-25px");
        $("#kcinema>li>span").css("margin-right", "25px");
    });
    $("#selcinemalch").mouseout(function () {
        $("#kchcinemaname").removeClass("newselh");
        $("#kchcinemaname > b").removeClass("newselhb");
        $("#cinemasearchnew").hide();
    });
    $("#seltimelch").mouseout(function () {
        $("#kchshowname").removeClass("newselh");
        $("#kchshowname > b").removeClass("newselhb");
        $("#ktimesearchnew").hide();
    }); kchangefilm2(cid); kchangecinema2(cid);

    $("#seltimelch").mouseover(function () {

        if ($("#kchfilmname").html() == '选择影片' && $("#kchcinemaname").html() == '选择影院') {
            $("#noteid").html("请先选择影片或影院");
        }
        if ($("#kchfilmname").html() == '选择影片' && $("#kchcinemaname").html() != '选择影院') {
            $("#noteid").html("你还没选择影片");
        }
        if ($("#kchfilmname").html() != '选择影片' && $("#kchcinemaname").html() == '选择影院') {
            $("#noteid").html("你还没选择影院");
        }
        $("#kchshowname").addClass("newselh");
        $("#kchshowname > b").addClass("newselhb");
        $("#ktimesearchnew").show();
        $("#cinemasearchnew").hide();
        $("#moviesearchnew").hide();
    });

    /***** 20110909 *****/
    $("#test_id").hover(function () { //选择影片的
        $(this).parent().parent().eq(1).show();
    },
  function () {
      $(this).parent().parent().eq(1).hide();
  })

    $("#test_id2").hover(function () { //选择影院的
        $(this).parent().parent().eq(1).show();
    },
  function () {
      $(this).parent().parent().eq(1).hide();
  })

    $("#today").hover(function () { //电影时间的
        $(this).eq(0).show();
    }, function () {
        $(this).eq(0).hide();
    })
    /***** 20110909 end *****/

    $("#selmovielch").hover(function () {
        $("#kchfilmname").css("z-index", "1002");
    }, function () {
        $("#kchfilmname").css("z-index", "1");
    })

    $("#selcinemalch").hover(function () {
        $("#kchcinemaname").css("z-index", "1001");
    }, function () {
        $("#kchcinemaname").css("z-index", "1");
    })

    $("#ktimesearchnew").hover(function () {
        $("#kchshowname").css("z-index", "0");
    }, function () {
        $("#kchshowname").css("z-index", "1001");
    })

    $("#selmovielch").hover(function () {
        $(".searlvideo_input").css("z-index", "99999");
    }, function () {
        $(".searlvideo_input").css("z-index", "0");
    })
})

function showxiaoguo() {
    /***** 20110909 *****/
    $(".topic").hover(function () { //选择影片的
        $(this).parent().next().show();
    }, function (event) {
        $(this).parent().next().hide();
        event.stopPropagation();
    })


    $(".today").hover(function () { //电影时间的
        $(this).children().show();
    }, function () {
        $(this).children().hide();
    })
    /***** 20110909 *****/
}

function kchangeshow(kfilmid, kcinemaid, kcinemaname) {
    //alert("g");
    $("#kshow").html("正在加载");
    $("#kchcinemaname").html(kcinemaname);
    $("#cinemasearchnew").hide();

    $("#kshow").load("/Users/showtime.aspx?kfilmid=" + kfilmid + "&kcinemaid=" + kcinemaid);
    //$("#ktimesearchnew").show();
}

function kshowfilmofcinema(cinemaindex, cinemaname) {
    //alert("kfilm5");
    $("#kshow").html("请先选择影片");
    $("#kchfilmname").html('选择影片');
    $("#kchcinemaname").html(cinemaname);
    $("#cinemasearchnew").hide();
    $("#kfilm").html("");
    $.ajax({ type: 'POST', url: '/Users/indexsearchyin.aspx', data: { "cinemaindex": cinemaindex, "sort": "5" },
        success: function (data) {
            if (data != "-1") {
                $("#kfilm").html(data);
                showxiaoguo();
            }
        }
    });
    //$("#moviesearchnew").show();
}

function kchangecinema(kcityid, kfilmid, kfilmname) {
    //alert("e");
    $("#kshow").html("请先选择影院");
    $("#kchcinemaname").html('选择影院');
    $("#kcinema").html("");
    //$("#cinemasearchnew").show();
    $("#kchfilmname").html(kfilmname);
    $("#moviesearchnew").hide();

    $("#kcinema").load("/Users/filmcinema.aspx?kcityid=" + kcityid + "&kfilmid=" + kfilmid);


}

function kchangeshow2(kfilmid, kcinemaid, kfilmname) {
    //alert("a");
    $("#kshow").html("正在加载");
    $("#kchfilmname").html(kfilmname);
    $("#moviesearchnew").hide();
    $.ajax({ type: 'POST', url: '/Users/indexsearchyin.aspx', data: { "kcinemaid": kcinemaid, "kfilmid": kfilmid, "sort": "3" },
        success: function (data) {
            if (data != "-1") {
                $("#kshow").html(data);
                showxiaoguo();
            }
        }
    });
    //$("#ktimesearchnew").show();
}
function kchangecinema2(kcityid) {
    //alert("b");
    $("#kcinema").html("");

    $("#kcinema").load('/Users/cinema' + kcityid + '.html');

}

function kchangefilm2(kcityid) {
//    alert("dd");
    //    alert("cityid=" + kcityid);

    //alert("kfilm4");
    $("#kfilm").html("");
    //加载指定城市Id的热映电影
    $("#kfilm").load('/Users/film/' + kcityid + '.html');
    //alert('/Users/film/' + kcityid + '.html');
}

function kchangecity2(kcityid) {
    //alert("d");
    var kcityn = "合肥";
    switch (kcityid) {
        case "1":
            kcityn = "合肥";
            break;
        case "2":
            kcityn = "芜湖";
            break;
        case "3":
            kcityn = "安庆";
            break;
        case "4":
            kcityn = "马鞍山";
            break;
        case "5":
            kcityn = "六安";
            break;
        case "6":
            kcityn = "蚌埠";
            break;
        case "7":
            kcityn = "淮南";
            break;
        case "8":
            kcityn = "淮北";
            break;
        case "10":
            kcityn = "铜陵";
            break;
        case "9":
            kcityn = "黄山";
            break;
        case "10":
            kcityn = "黄山";
            break;
        case "11":
            kcityn = "滁州";
            break;
        case "12":
            kcityn = "阜阳";
            break;
        case "13":
            kcityn = "宿州";
            break;
        case "14":
            kcityn = "巢湖";
            break;
        case "15":
            kcityn = "毫州";
            break;
        case "16":
            kcityn = "池州";
            break;
        case "17":
            kcityn = "宣城";
            break;
    }
    $("#yinchangecity2").html(kcityn + "[更换城市]");

}
